package org.crazyit.activiti_d2._9_GroupQuery;

import org.activiti.engine.IdentityService;
import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngines;
import org.activiti.engine.identity.Group;

import java.util.List;

public class GroupQuery {

    public static void main(String[] args) {

        //1. 创建流程引擎
        ProcessEngine engine = ProcessEngines.getDefaultProcessEngine();

        //2. 得到身份服务组件实例
        IdentityService identityService = engine.getIdentityService();

        //3. groupId 方法
        Group groupD = identityService.createGroupQuery().groupId("4").singleResult();
        System.out.println("groupId method: " + groupD.getId());

        //4. groupName 方法
        Group groupC = identityService.createGroupQuery().groupName("GroupC").singleResult();
        System.out.println("groupName method: " + groupC.getName());

        //5. groupType 方法
        Group groupE = identityService.createGroupQuery().groupType("typeE").singleResult();
        System.out.println("groupType method: " + groupE.getType());

        //6. groupNameLike 方法
        List<Group> groups = identityService.createGroupQuery().groupNameLike("%Group%").list();
        System.out.println("groupNameLike method: " + groups.size());

    }

}
